<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app2">
        <!-- v-model其实是一个语法糖，它实际做了两步动作：
        1、绑定数据value
        2、内容改变时触发输入事件input，获取当前value值赋值 -->
        <div id="app">
            {{username}}<br />
            <input type="text" :value="username" @input="btnClick($event)">
        </div>
    </div>
</body>
<script src="vue.js"></script>
<script>
    var vm = new Vue({
        el: "#app2",
        data: {
            username: 'admin'
        },
        methods: {
            btnClick(enter) {
                this.username = enter.target.value
            }
        },
    })
</script>

</html>